var locomotive = require('locomotive');
var requestIP = require("request-ip");

var Controller = locomotive.Controller;

var testController = new Controller();

testController.before('main', function(next) {
    this.ip = requestIP.getClientIp(this.req);
    next();
});

testController.main = function() {
    var self = this;
    var result = {status: 1, msg: this.ip};
    this.respond({
        'json': function () {
            self.res.jsonp(result);
        }
    })
}

module.exports = testController;